package com.ychs.lawyer.exception;

import com.ychs.lawyer.bean.R;
import com.ychs.lawyer.bean.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: clh
 * @Date: 2024/07/18/15:51
 * @Description:全局处理,当怕怕出
 */
@RestControllerAdvice
@Slf4j
public class ControllerExceptionAdvice {
    @ExceptionHandler(value = Exception.class)
    public R<?> CommonException(Exception e){
        log.error("统一的异常处理",e);
        return R.fail(ResultCode.ERROR);
    }



    @ExceptionHandler(value = com.ychs.lawyer.exception.BussinessException.class)
    public R<?>BussinessException(com.ychs.lawyer.exception.BussinessException e) {
        log.error("业务异常",e.getCode(),e.getMessage());
        return R.fail(e.getCode(),e.getMessage());
    }
}
